class Bird extends GuaAnimation {
    constructor(game) {
        super(game)
        this.name = 'bird'
    }
    addAnimation() {
        this.animations = {
            idle: [],
        }
        this.animationCount = {
            idle: 4,
        }
    }

    setUp() {
        super.setUp()
        this.frames = this.animations['idle']

        this.gy = 5        
        this.vy = 0
    }

    // run(x,keyStatus) {
    //     this.move(x, 0)
    //     if (this.jumping != null) {
    //         return
    //     }
    //     this.flipX = x < 0
    //     var animationNames = {
    //         keydown: 'run', 
    //         keyup: 'idle',
    //     }
    //     var name = animationNames[keyStatus]
    //     this.changeAnimation(name)        
    // }

    jump(height, keyStatus) {
        if (this.alive == false) {
            return
        }
        if (keyStatus == 'keyup') {
            return
        }
        this.vy = -height
        this.rotation = -45
    }

    snakeShapUp() {
        pass
    }

    freeFall() {
        this.vy += this.gy * 0.3
        this.move(0, this.vy)
        if (this.rotation < 45) {
            this.rotation += 5 
        }
    }

    update() {
        super.update()
        this.freeFall()
        if (this.y >= 300) {
            this.setPosition(this.x, 300) 
            this.changeAnimation('idle')
        }

    }
    draw() {
        super.draw()
    }
}